﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=8" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta property="qc:admins" content="07216227476305205456375" />

		<title>用户注册</title>
		<link href="css/shoppingCarAndMyCustom.css" type="text/css"
			rel="stylesheet" />
		<link href="css/login.css" type="text/css" rel="stylesheet" />
		<script src="jquery/js/jquery-1.8.2.js"></script>
<script src="jquery/js/jquery-ui-1.8.23.custom.js"></script>
<link rel="stylesheet" href="jquery/css/ui-lightness/jquery-ui-1.9.0.custom.css" />
		<script type="text/javascript" src="js/login.js"></script>

		<script type="text/javascript" src="js/myCustonAndShoppingCar/bgiframe.js"></script>
<script type="text/javascript" src="js/myCustonAndShoppingCar/weebox.js"></script>
<link type="text/css" rel="stylesheet" href="css/xixiaoming/weebox.css" />

<style type="text/css">
Input{
	border:1px solid;border-color:#807070
}
.denglu a{background-image:url("thirdparty/denglu_icon5_all_bg.png");font-size:27px;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .renren{background-position:0px -180px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .baidu{background-position:0px -450px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .sina{background-position:0px -60px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .tencent{background-position:0px -90px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .taobao{background-position:0px -360px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .douban{background-position:0px -240px;width: 24px;height:24px;background-repeat:no-repeat;}
</style>
	</head>
	<script type="text/javascript">
	$(document).ready(function() {
        var openId = $("#hiddenthirdpartyid").val();

	$.post("checkThirdPartyJson", {
			"openid" : openId
		}, function(data) {
			if (data.msg == 'true') {
				$("#hiddenthirdpartyid").val("");
				$("#thirdTypeId").val("");
				$("#screenName").val("");
			} else {
			}
		});
	});
	var bopenid;
	function yanopenid() {

		var oid = $("#hiddenthirdpartyid").val();

		$.post("checkOpenId.action", {
			openid : oid
		}, function(data) {

			var username = data.username;
			if (data.username != null) {
				bopenid = 1;
			} else {
				bopenid = 2;
			}
		});
		setTimeout(function() {
		}, 500);
		return bopenid;
	}

	function register() {

		yanname();
		email();
		yancon();
		yanpass();
		if(ypass&&ycon&&ymail&&yname1){
			$.ajax( {
				type : 'post',
				url : 'getSession.action',
				data : {
					sessionid : "rand"
				},
				success : function(data) {

					if ($("#validataimg").val() != data.value) {
						alert("验证码错误，请重新输入");
						$("#validataimg").val("");
						chageValidateCode();
					} else {

						var oid = $("#hiddenthirdpartyid").val();
						window.location.href = "register.action?email="
								+ $("#mail").val() + "&&password="
								+ $("#password").val() + "&&thirdPartyId="
								+ $("#hiddenthirdpartyid").val() + "&&thirdTypeId="
								+ $("#thirdTypeId").val();

					}
				},
				datatype : 'json'
			});
		}
	}
	function sendDisignRigister() {

		$("#dmail").val($("#mail").val());
		$("#hpassword").val($("#password").val());
		$("#uname").val($("#mail").val());
		var f = document.getElementById("designform");
		f.action = "designRegisterAction";
		f.submit();
	}
	function chageValidateCode() {
		var timenow = new Date().getTime();
		$("img.validate").attr("src", "showCheckCode.action?d=" + timenow);
	}

	var reg = /^(\w){2,15}$/;
	var youxiang = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	var ypass = false;
	var ycon = false;
	var ymail = false;
	var yname1 = false;

	function yanname() {

		var name = $('#username').val();

		if (name == "") {
			yname1 = false;
			$('#usernamefont').css("color", "red");
			$('#usernamefont').html("用户名不能为空！");
		} else {
			$.post("yanuser.action", {
				"username" : name
			}, function(data) {

				if (data == "false") {
					yname1 = false;
					$('#usernamefont').css("color", "red");
					$('#usernamefont').html("用户名已存在");
				} else {
					$('#usernamefont').css("color", "green");
					$('#usernamefont').html("√");
					yname1 = true;

				}
			});

		}
	}

	function yanpass() {

		var pass = $('#password').val();
		var passfont = $('#passfont');

		if (pass != "" && pass != null) {
			if (reg.test(pass)) {

				ypass = true;
				passfont.css("color", "green");
				passfont.html("√");
			} else {
				passfont.css("color", "red");
				passfont.html("长度要在2-15位之间");
			}
		} else {
			passfont.css("color", "red");
			passfont.html("密码不能为空");
		}

	}

	function yancon() {

		var pass = $('#password').val();
		var con = $('#confirm').val();
		var confont = document.getElementById("confont");

		if (con != "" && con != null) {
			if (con == pass) {
				ycon = true;
				confont.style.color = "green";
				confont.innerHTML = "√";
			} else {
				confont.style.color = "red";
				confont.innerHTML = "密码不一致";
			}
		} else {
			confont.style.color = "red";
			confont.innerHTML = "确认密码不能为空";
		}
	}

	function email() {
		var kkmail = $('#mail').val();
		var mailfont = $('#mailfont');

		$.post("yanemail.action", {
			email : kkmail
		}, function user(data) {
			if (kkmail != "" && kkmail != null) {
				if (data.str == "false") {
					mailfont.css("color", "red");
					mailfont.html("此用户名已被注册");
				} else {
					if (youxiang.test(kkmail)||/^1[3|4|5|8][0-9]\d{4,8}$/.test(kkmail)) {
						ymail = true;
						mailfont.css("color", "green");
						mailfont.html("√");
					} else {

						mailfont.css("color", "red");
						mailfont.html("手机号或者邮箱");
					}
				}
			} else {
				mailfont.css("color", "red");
				mailfont.html("用户名不能为空");
			}
		}, "json");
	}
	var yCode = false;
	function yanCode() {
		var code = $('#validataimg').val();
		$.ajax( {
			type : 'post',
			url : 'getSession.action',
			data : {
				sessionid : "rand"
			},
			success : function(data) {

				if ($("#validataimg").val() != data.value) {
					alert("验证码错误，请重新输入");
					chageValidateCode();
					$("#codefont").html("&nbsp;&nbsp;");
				} else {
					yCode = true;
					$("#codefont").html("√");
				}
			},
			datatype : 'json'
		});
	}
	function showdesignerrig() {

		if (document.getElementById("bedesigner").checked == false) {
			document.getElementById("bedesigner").checked = false;
		} else {
			document.getElementById("bedesigner").checked = true;
		}
		$("#designerrig").fadeToggle();
	}
	function oload() {

	}
</script>


	<body onload="oload()" style="clear:both;width: 100%; text-align:center;margin: 0px; padding: 0px;">


		<input type="hidden" value="${openid }" id="hiddenthirdpartyid" />
        <input type="hidden" value="${thirdTypeId }" id="thirdTypeId"/>

		<script type="text/javascript">

						function completeregiest(){
							if($("#ctruename").val()==""||$("#ctruename").val()==null){
									alert("真实姓名不能为空");
							}else if($("#cphonenumber").val()==""||$("#cphonenumber").val()==null){
									alert("电话号码不能为空");
							}else if($("#cidentitycard").val()==""||$("#cidentitycard").val()==null){
									alert("身份证号码不能为空");
							}else{
									var ff=document.getElementById("completeform");
									ff.action="BecomeTheDesignerAction";
									ff.submit();
							}
						}
						function beDesigner(message){
							if(message=="success"){
								alert("恭喜你 ，您已经成为了设计师");
								location.href="ShowMyCustom";
								$("#ctruename").val("");
								$("#cphonenumber").val("");
								$("#cidentitycard").val("");
							}else{
								alert("成为设计师失败，可联系网贝网络公司");
								$("#ctruename").val("");
								$("#cphonenumber").val("");
								$("#cidentitycard").val("");
							}
						}
	</script>
		<jsp:include page="top.jsp"></jsp:include>
		<br />
		<c:choose>
			<c:when test="${session.username!=null}">
				<div id="completeregiest" align="center">
					<table>
						<tr>
							<td>
								<div id="designerrig" style="padding-left: 25px;">
									<form method="post" enctype="multipart/form-data"
										id="completeform" target="com_iframe">
										<table>
											<tr>
												<td>
													<font class="ziti2">真实名称</font>
												</td>
												<td>
													<input type="text" style="border:1px solid;border-color:#807070" name="ctruename" id="ctruename">
												</td>
											</tr>
											<tr>
												<td>
													<font class="ziti2">电话号码</font>
												</td>
												<td>
													<input type="text" style="border:1px solid;border-color:#807070" name="cphonenumber" id="cphonenumber">
												</td>
											</tr>
											<tr>
												<td>
													<font class="ziti2">身份证号码</font>
												</td>
												<td>
													<input type="text" style="border:1px solid;border-color:#807070" name="cidentitycard" id="cidentitycard">
												</td>
											</tr>
											<tr>
												<td>
													<font class="ziti2">身份证复印件</font>
												</td>
												<td>
													<input type="file" name="ccardfile" id="ccardfile">
												</td>
											</tr>
											<tr>
												<td colspan="2">
													<div style="color: grey;width:700px;height:400px;overflow:scroll;font-family:'微软雅黑';margin-top:30px;">
														<font size="2px;">
															<jsp:include page="agreement.jsp"></jsp:include>
														</font>
													</div>

												</td>
											</tr>
											<tr align="center">
												<td colspan="2">
													<input type="button" value="同意以上条款并注册"
														onclick="completeregiest()">
												</td>
											</tr>
										</table>
										<iframe id="com_iframe" name="com_iframe"
											style="display: none;"></iframe>
									</form>
								</div>
							</td>
						</tr>
					</table>
				</div>
			</c:when>
			<c:otherwise>
				<div id="registerid" style="width:455px;margin:0 auto;text-align:center;">
								<table width="455px">
									<tr align="left">
										<td colspan="2">
											<font class="ziti1">使用其他账户直接登录：</font><font color="red" id="screenName">${screenName }</font>
											<p class="denglu" style="margin-left:0px;font-family:'微软雅黑';font-size:14px;">第三方登录：
		<a class="tencent" href="http://open.denglu.cc/transfer/tencent?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp" target="_blank">
		<img src="images/png/400300.png" height="24" width="24" title="腾讯微博"/></a>
		<a class="qzone" href="http://open.denglu.cc/transfer/qzone?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp">
		<img src="images/png/400300.png" height="24" width="24" title="腾讯QQ"/></a>
		<a class="sina" href="http://open.denglu.cc/transfer/sina?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp">
		<img src="images/png/400300.png" height="24" width="24" title="新浪微博"/></a>
		<a class="renren" href="http://open.denglu.cc/transfer/renren?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp">
		<img src="images/png/400300.png" height="24" width="24" title="人人网"/></a>
		<a class="taobao" href="http://open.denglu.cc/transfer/taobao?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp">
		<img src="images/png/400300.png" height="24" width="24" title="淘宝网"/></a>
		<a class="douban" href="http://open.denglu.cc/transfer/douban?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp">
		<img src="images/png/400300.png" height="24" width="24" title="豆瓣网"/></a>
		<a class="baidu" href="http://open.denglu.cc/transfer/baidu?appid=52645&redirect_uri=http%3A%2F%2Fwww.webbei.com%2Fregister.jsp">
		<img src="images/png/400300.png" height="24" width="24" title="百度连接"/></a>
		</p>
										</td>
									</tr>
									<tr align="left">
										<td colspan="2">
											<div style="width: 130%;margin-top:10px;">
												<font class="ziti1">选择注册新账号登录：</font>
											</div>
										</td>
									</tr>
									<tr align="left">
										<td>
											<font class="ziti2" style="margin-left:32px;">用户名：</font></td><td>
											<input type="text" name="mail" id="mail" style="color:#A1A1A1;border:1px solid;border-color:#807070" onblur="email()"
												style="width: 220px;" value="请填写邮箱或者手机号" onfocus="$(this).val('');$(this).css('color','black');"/>
											<font id="mailfont" size="2" color="red"></font>
										</td>
									</tr>
									<tr align="left">
										<td>
												<font class="ziti2" style="margin-left:32px;">设置登陆密码：</font></td><td>
												<input type="password" name="password" id="password" style="border:1px solid;border-color:#807070"
													onblur="yanpass()" style="width: 195px;" />
												<font id="passfont" color="red" size="2"></font>
										</td>
									</tr>
									<tr align="left">
										<td>
												<font class="ziti2" style="margin-left:32px;">确认登录密码：</font></td><td>
												<input type="password" name="confirm" id="confirm" style="border:1px solid;border-color:#807070"
													onblur="yancon()" style="width: 195px;" />
												<font id="confont" color="red" size="2"></font>
										</td>
									</tr>
									<tr align="left">
										<td>
											<font class="ziti2" style="margin-left:32px;">验证码：</font></td><td>
											<input type="text" id="validataimg" style="border:1px solid;border-color:#807070;width: 80px;" onblur="yanCode()" />
											<font color="green" id="codefont">&nbsp;&nbsp;</font>
											<img class="validate" src="showCheckCode.action"
												style="width: 65px; height: 15px" />
											<font class="ziti3">看不清？</font>
											<a href="javascript:void()" onclick="chageValidateCode()">换一张</a>
										</td>
									</tr>
									<tr align="left">
										<td colspan="2">
											<font class="ziti4">请阅读《webbei网贝服务条款》</font>
										</td>
									</tr>
									<tr align="left">
										<td colspan="2">
											<font><a>注册成为新产品设计师,获取版权分成</a>
											</font>
											<input type="checkbox" id="bedesigner"
												onchange="showdesignerrig()">
										</td>
									</tr>
									<tr align="left">
										<td colspan="2">
											<div id="designerrig"
												style="display: none; padding-left: 25px;">
												<form method="post" enctype="multipart/form-data"
													id="designform">
													<table>
														<tr>
															<td>
																<font class="ziti2">真实名称</font>
															</td>
															<td>
																<input type="text" name="truename" id="truename" style="border:1px solid;border-color:#807070">
															</td>
														</tr>
														<tr>
															<td>
																<font class="ziti2">电话号码</font>
															</td>
															<td>
																<input type="text" name="phonenumber" id="phonenumber" style="border:1px solid;border-color:#807070">
															</td>
														</tr>
														<tr>
															<td>
																<font class="ziti2">身份证号码</font>
															</td>
															<td>
																<input type="text" name="identitycard" id="identitycard" style="border:1px solid;border-color:#807070">
															</td>
														</tr>
														<tr>
															<td>
																<font class="ziti2">身份证复印件</font>
															</td>
															<td>
																<input type="file" name="cardfile" id="cardfile" style="border:1px solid;border-color:#807070">
															</td>
														</tr>
														<tr>
															<td colspan="2">
																<div style="color: grey;width:550px;height:251px;overflow:scroll;font-size:14px;font-family:'微软雅黑'">
																	<jsp:include page="agreement.jsp"></jsp:include>
																</div>
																<input type="hidden" name="dmail" id="dmail">
																<input type="hidden" name="uname" id="uname">
																<input type="hidden" name="hnickname" id="hnickname">
																<input type="hidden" name="hpassword" id="hpassword">
															</td>
														</tr>
													</table>
												</form>
											</div>
										</td>
									</tr>
									<tr>
										<td style="text-align:center;" colspan="2">
											<input type="button" value="同意以上条款并注册" id="sub"
											style="background-color:#ccc;color:#333;font-weight:bold;cursor:pointer;font-family:'微软雅黑';"
												onclick="register()" />
										</td>
									</tr>
								</table>
				</div>
			</c:otherwise>
		</c:choose>



		<jsp:include page="bottom.jsp"></jsp:include>
	</body>
</html>
